#ifndef prs_odbTable_H
#define prs_odbTable_H

#include "prs_odbNodes.h"

namespace prs
{

struct TNodeOdbString : public TNodeOdb {
	TNodeOdbString(): size(this), NodeType(this) { size.SetValue(-1); }
	virtual TNode *New() { return new TNodeOdbString; }
	virtual void odbSync( TOdbParams Params );
	virtual TAttrNodeTypeBase* GetType(){
		char* g = NodeType.GetValue();
		return &NodeType;
	}

	TAttrNodeType<nodeType_String> NodeType;
	TAttrInteger<attrName_Size> size;
};

struct TNodeOdbRef : public TNodeOdb {
	TNodeOdbRef(): toTable(this), NodeType(this) {}
	virtual TNode *New() { return new TNodeOdbRef; }
	virtual void odbSync( TOdbParams Params );
	virtual TAttrNodeTypeBase* GetType(){
		return &NodeType;
	}

	TAttrNodeType<nodeType_Ref> NodeType;
	TAttrString<attrName_ToTable> toTable;
};

struct TNodeOdbRefG : public TNodeOdb {
	TNodeOdbRefG(): NodeType(this) {}
	virtual TNode *New() { return new TNodeOdbRefG; }
	virtual void odbSync( TOdbParams Params );
	virtual TAttrNodeTypeBase* GetType(){
		return &NodeType;
	}

	TAttrNodeType<nodeType_RefG> NodeType;
};

struct TNodeOdbDatetime : public TNodeOdb {
	TNodeOdbDatetime(): NodeType(this) {}
	virtual TNode *New() { return new TNodeOdbDatetime; }
	virtual void odbSync( TOdbParams Params );
	virtual TAttrNodeTypeBase* GetType(){
		return &NodeType;
	}

	TAttrNodeType<nodeType_Datetime> NodeType;
};

struct TNodeOdbDouble : public TNodeOdb {
	TNodeOdbDouble(): NodeType(this) {}
	virtual TNode *New() { return new TNodeOdbDouble; }
	virtual void odbSync( TOdbParams Params );
	virtual TAttrNodeTypeBase* GetType(){
		return &NodeType;
	}

	TAttrNodeType<nodeType_Double> NodeType;
};

struct TNodeOdbInteger : public TNodeOdb {
	TNodeOdbInteger(): NodeType(this) {}
	virtual TNode *New() { return new TNodeOdbInteger; }
	virtual void odbSync( TOdbParams Params );
	virtual TAttrNodeTypeBase* GetType(){
		return &NodeType;
	}

	TAttrNodeType<nodeType_Integer> NodeType;
};

struct TNodeOdbTable : public TNodeOdb {
	TNodeOdbTable(): NodeType(this) {}
	virtual TNode *New() { return new TNodeOdbTable; }
	virtual void odbSync( TOdbParams Params );
	virtual TAttrNodeTypeBase* GetType(){
		return &NodeType;
	}

	TAttrNodeType<nodeType_Table> NodeType;
};

struct TRuleOdbTable : public snt::TRule{
	
	TRuleOdbTable::TRuleOdbTable( snt::text::TContext &Context, svl::TVariant &Parent);

	static void FAddAttr(snt::TParams &Params);
	static void FCheckId(snt::text::TIdent::TFuncDoEntryParams &Params);
	static void FCheckTableId(snt::text::TIdent::TFuncDoEntryParams &Params);
	
	svl::TVariant Name, Numb, &parent, This, AttrName;
	
	snt::TAlter A1, A2, AStr, ARef;
	snt::TRule  RTableAttr;
};

}
#endif

